<?php  
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Retrieve
{
    
    function Retrieve()
    {
    	$this->obj =& get_instance();
    }
	
    function post($fields = array()) {
    	if(empty($fields)) return false;
    	$return = array();
    	if(!empty($fields)) {
    		foreach($fields as $field) {
    			$value = $this->obj->input->post($field);
    			$return[$field] = empty($value) ? 0 : $value;
    		}
    	}
    	return $return;
    }
    
	function get($fields = array()) {
    	if(empty($fields)) return false;
    	$return = array();
    	if(!empty($fields)) {
    		foreach($fields as $field) {
    			$value = $this->obj->input->get($field);
    			$return[$field] = empty($value) ? 0 : $value;
    		}
    	}
    	return $return;
    }
    
    function required($fields = array(), $data = array()) {
    	if(empty($fields) || empty($data)) return false;
    	if(!empty($fields)) {
    		foreach($fields as $key => $field) {
    			if($key ==0) {
    				if(!empty($data[$field])) {
    					$status = true;
    				}
    			} else {
		    		if(!empty($data[$field])) {
		    			$status = $status & true;
		    		}
    			}
    		}
    	}
    	return $status;
    }
}